/**
 * File    : Border.java
 * Created : 2008-9-5
 * By      : LuHuiguo
 */
package com.luhuiguo.sso.tutorial.components;

import java.security.Principal;

import org.apache.tapestry5.Asset;
import org.apache.tapestry5.annotations.Path;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.services.RequestGlobals;

/**
 * @author LuHuiguo
 * @version $Id: Border.java 2 2008-10-04 13:04:21Z LuHuiguo $
 * 
 */
public class Border {
	@Inject
	@Path("context:assets/images/favicon.ico")
	private Asset icon;

	@Inject
	@Path("context:assets/styles/style.css")
	private Asset styles;

	@Inject
	private Request request;

	@Inject
	private RequestGlobals requestGlobals;

	/**
	 * @return the icon
	 */
	public Asset getIcon() {
		return icon;
	}

	/**
	 * @return the styles
	 */
	public Asset getStyles() {
		return styles;
	}

	/**
	 * @return the logoutUrl
	 */
	public String getLogoutUrl() {
		return request.getContextPath() + "/j_spring_security_logout";
	}

	public String getUsername() {
		Principal principal = requestGlobals.getHTTPServletRequest()
				.getUserPrincipal();

		return principal == null ? "" : principal.getName();
	}
}
